/**
 * The Class Timer.
 */
public class Timer
{
	/** The delay. */
	private int delay;
	/** The time. */
	private int time;

	/**
	 * Instantiates a new timer.
	 */
	public Timer()
	{
		this(0);
	}

	/**
	 * Instantiates a new timer.
	 * 
	 * @param delay
	 *            the delay
	 */
	public Timer(final int delay)
	{
		setDelay(delay);
	}

	/**
	 * Force activate.
	 */
	public void forceActivate()
	{
		time = 0;
	}

	/**
	 * Gets the current.
	 * 
	 * @return time needed to activate the timer
	 */
	public int getCurrent()
	{
		return time;
	}

	/**
	 * Gets the delay.
	 * 
	 * @return the delay
	 */
	public int getDelay()
	{
		return delay;
	}

	/**
	 * Checks if is active.
	 * 
	 * @return true, if is active
	 */
	public boolean isActive()
	{
		return time <= 0;
	}

	/**
	 * Reset.
	 */
	public void reset()
	{
		time = delay;
	}

	/**
	 * Sets the delay.
	 * 
	 * @param delay
	 *            the new delay
	 */
	public void setDelay(final int delay)
	{
		this.delay = delay;
		reset();
	}

	/**
	 * Update.
	 * 
	 * @param elapsedTime
	 *            the elapsed time
	 */
	public void update(final int elapsedTime)
	{
		time -= elapsedTime;
	}

	/**
	 * Verify.
	 * 
	 * @param elapsedTime
	 *            the elapsed time
	 * @return true, if successful
	 */
	public boolean verify(final int elapsedTime)
	{
		update(elapsedTime);
		if (isActive())
		{
			reset();
			return true;
		}
		else
		{
			return false;
		}
	}
}